import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login',  // 重定向:重新指向其它path,会改变网址
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "about" */ '../page/login.vue')
  },
  {
    path: '/main',
    name: 'main',
    component: () => import(/* webpackChunkName: "about" */ '../page/main.vue'),
    children:[
        {
            path: '/main/xx1',
            name: 'xx1',
            component: () => import(/* webpackChunkName: "about" */ '../page/xx1.vue'),
        },
        {
            path: '/main/xx2',
            name: 'xx2',
            component: () => import(/* webpackChunkName: "about" */ '../page/xx2.vue'),
        },
        {
            path: '/main/dh2',
            name: 'dh2',
            component: () => import(/* webpackChunkName: "about" */ '../page/dh2.vue'),
        },
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
